<template>
  <!-- BMS电池簇 -->
  <div class="bmsContent">
    <a-spin :spinning="bmsLoading">
      <div class="bmsBox" v-for="(item, index) in defaultData" :key="index">
        <div class="title">{{ item.linkName }}-{{ item.blockName }}</div>
        <a-card class="content">
          <template #title>
            <div class="header">
              <div
                v-for="(headerItem, headerIndex) in item.titleList"
                :key="headerIndex + headerItem.pdId"
              >
                {{ headerItem.name }}：<span v-param="headerItem.pdId">{{
                  headerItem.value
                }}</span>
              </div>
            </div>
          </template>
          <div class="data">
            <div
              v-for="(dataItem, dataIndex) in item.contentList"
              :key="dataIndex + dataItem.pdId"
            >
              {{ dataItem.name }}：<span v-param="dataItem.pdId">{{ dataItem.value }}</span>
            </div>
          </div>
        </a-card>
      </div>
      <a-empty
        v-if="!defaultData.length"
        style="opacity: 0.5; margin-top: 50px"
      />
    </a-spin>
  </div>
</template>
<script setup>
;
const props = defineProps({
  stationInfo: {
    type: Number,
  },
});
const defaultData = ref([]);
const $api = inject("$api");
const bmsLoading = ref(false);
const getbmsCurve = async () => {
  bmsLoading.value = true;
  const res = await $api.bmsCurve({
    stationId: props.stationInfo.id,
  });
  bmsLoading.value = false;
  if (res?.code === 0) {
    defaultData.value = res.data;
  }
};
const handleChageStation = () => {
  getbmsCurve();
};
defineExpose({ handleChageStation });
</script>

<style lang="less" scoped>
.bmsContent {
  overflow-y: auto;
  height: calc(100vh - 270px);
  width: 100%;
}
.bmsBox {
  width: 100%;
  min-height: 100px;
  .title {
    font-size: 20px;
    margin: 30px 0 12px 0;
  }
  .header {
    font-size: 16px;
    div {
      display: inline-block;
      width: 25%;
    }
  }
  .data {
    div {
      display: inline-block;
      width: 25%;
      margin-bottom: 24px;
    }
  }
}
::v-deep(.ant-card-body) {
  padding: 24px 24px 0 24px;
}
</style>